package com.mrper.util.share;

import android.app.Activity;

import com.miguo.plugins.share.ShareQQActivity;
import com.miguo.plugins.share.ShareWXUtils;
import com.miguo.ui.R;
import com.miguo.utils.WebJsApi;
import com.miguo.view.listener.ShareListener;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/8/26.
 * 分享链接的辅助方法
 */

public class ShareLinkUtil {

    public static String PARAM_TITLE = "title";

    public static String PARAM_DESCRIPTION = "desc";

    public static String PARAM_IMAGE_URL = "image_url";

    public static String PARAM_URL = "url";

    public static String PARAM_APP_NAME = "app_name";

    /** 在微信分享中，1表示朋友圈，0-表示朋友分享。在QQ中，1-QQ,0-Qzone  **/
    public static String PARAM_SCENE = "scene";

    public static String PARAM_SHARE_TYPE_WX_WEBPAGE = "type";

//------------------------------------------------------------------------------------------------------------------------------

    public final static int TYPE_WX = 0;

    public final static int TYPE_QQ = 1;

    /**
     * 分享到？？？
     * @param activity
     * @param type {@link ShareLinkUtil#TYPE_WX} & {@link ShareLinkUtil#TYPE_QQ}
     * @param jsonParams 要分享的内容参数
     * @param shareListener
     */
    public static void shareTo(Activity activity, int type, JSONObject jsonParams, ShareListener shareListener) {
        try {
            switch (type) {
                case TYPE_WX:
                    jsonParams.put(PARAM_SHARE_TYPE_WX_WEBPAGE, ShareWXUtils.SHARE_DISPOSETYPE_WEBPAGE);
                    WebJsApi.shareWX(activity, jsonParams, shareListener);
                    break;
                case TYPE_QQ:
                    jsonParams.put(PARAM_APP_NAME, activity.getString(R.string.app_name));
                    ShareQQActivity.invoke(activity, jsonParams, shareListener);
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
